package algotithm.leetcode.matrix.interview1009;

/**
 * @author zhouyanxiang
 * @Date 2021-03-2021/3/13-22:58
 * @Title 面试题 10.09. 排序矩阵查找
 */
public class Solution {

    public boolean searchMatrix(int[][] matrix, int target) {
        int i = matrix.length - 1, j  = 0;
        while (i >= 0 && j < matrix[0].length) {
            if (target == matrix[i][j]) {
                return true;
            } else if (target < matrix[i][j]) {
                i--;
            } else {
                j++;
            }
        }
        return false;
    }
}
